// Datapump that indexes an array providing next, previous support
// Copyright 2006 (C) Ralph Thomas

#ifndef MISSION_DATAPUMPS_ARRAY_INDEX_H
#define MISSION_DATAPUMPS_ARRAY_INDEX_H

#include <adobe/dictionary.hpp>
#include <adobe/value.hpp>
#include <adobe/adam.hpp>

namespace datapumps {
	//
	/// The array_index datapump will index an array of dictionaries
	/// given a name in all of the dictionaries to index. Once it has
	/// done this it is able to report:
	///
	/// 1. The index # of a given value in the index.
	/// 2. The value that comes before.
	/// 3. The value that comes after.
	///
	/// The indexing is required to make the lookup of the index #
	/// fast, however, indexing will be slow for values that haven't
	/// been specialized for (and that provide operator<). Currently
	/// only values that are strings can be indexed (!).
	///
	/// The arguments required in the parameters dictionary are:
	///  <ul>
	///   <li><b>array</b>: The array to index.</li>
	///   <li><b>index_name</b>: The name of the value in the dictionaries
	///	to index.</li>
	///   <li><b>current</b>: The value that we want to know the index #,
	///	next and previous of.</li>
	///   <li><b>index</b>: The index number of "current".</li>
	///   <li><b>previous</b>: The value that preceeds "current", if any.</li>
	///   <li><b>next</b>: The value that comes after "current", if any.</li>
	///  </ul>
	///
	/// \param	parameters	the dictionary of parameters.
	/// \param	sheet		the sheet to bind into.
	///
	/// \return	a newly created array_index datapump.
	//
	adobe::value_t make_array_index_datapump( const adobe::dictionary_t& parameters, adobe::sheet_t& sheet );
}

#endif

